﻿using Engine;
using Engine.Graphics;
using Game;

namespace SAGhoul.Tartareosity
{
	public abstract class TartareosityCubeBlock : Block
	{
		static Texture2D texture;
		public override void Initialize()
		{
			base.Initialize();
			texture ??= ContentManager.Get<Texture2D>("Textures/Blocks_Tartareosity");
		}
		public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
		{
			generator.GenerateCubeVertices(this, value, x, y, z, Color.White, geometry.GetGeometry(texture).OpaqueSubsetsByFace);
		}

		public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
		{
			BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, color, color, environmentData, texture);
		}

		public override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
		{
			return new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, Color.White, GetFaceTextureSlot(4, value), texture);
		}
	}

	public class TartareosityDirtBlock : TartareosityCubeBlock
	{
	}

	public class TartareosityRockBlock : TartareosityCubeBlock
	{
	}

	public class TartareosityBasaltBlock : TartareosityCubeBlock
	{
		public override int GetFaceTextureSlot(int face, int value)
		{
			if (face == 4 || face == 5)
				return 0;
			return base.GetFaceTextureSlot(face, value);
		}

	}

}
